<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<% String path = request.getContextPath();%>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
    <!-- Google Chrome Frame也可以让IE用上Chrome的引擎: -->
    <meta name="renderer" content="webkit">
    <!--国产浏览器高速模式-->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="author" content="穷在闹市" />
    <!-- 作者 -->
    <meta name="revised" content="穷在闹市.v3, 2019/05/01" />
    <!-- 定义页面的最新版本 -->
    <meta name="description" content="网站简介" />
    <!-- 网站简介 -->
    <meta name="keywords" content="搜索关键字，以半角英文逗号隔开" />
    <title>baohan</title>

    <!-- 公共样式 开始 -->
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/base.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/iconfont.css">
    <script type="text/javascript" src="<%=path%>/static/js/jquery-1.11.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/layui/css/layui.css">
    <script type="text/javascript" src="<%=path%>/static/layui/layui.js"></script>
    <!-- 滚动条插件 -->
    <link rel="stylesheet" type="text/css" href="<%=path%>/static/css/jquery.mCustomScrollbar.css">
    <script src="<%=path%>/static/js/jquery-ui-1.10.4.min.js"></script>
    <script src="<%=path%>/static/js/jquery.mousewheel.min.js"></script>
    <script src="<%=path%>/static/js/jquery.mCustomScrollbar.min.js"></script>
    <script src="<%=path%>/static/js/cframe.js"></script><!-- 仅供所有子页面使用 -->
    <!-- 公共样式 结束 -->
    <link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.6.0/css/font-awesome.min.css">
    <link href="<%=path%>/static/css/time/foundation.min.css" rel="stylesheet" type="text/css">
    <link href="<%=path%>/static/css/time/foundation-datepicker.css" rel="stylesheet" type="text/css">
    <script src="<%=path%>/static/js/time/jquery-1.11.3.min.js"></script>
    <script src="<%=path%>/static/js/time/foundation-datepicker.js"></script>
    <script src="<%=path%>/static/js/time/foundation-datepicker.zh-CN.js"></script>


    <style>
        .layui-form-label{
            width: 100px;
        }
        .layui-input-block{
            margin-left: 130px;
            line-height: 36px;
        }
        .layui-form{
            margin-right: 30%;
        }
        .layui-select-title{
            margin-bottom: 10px;
        }

        input{
            background-color: white!important;
            width: 100%!important;
        }
        .user{
            font-weight: bold;
            font-size: 14px;
        }
        .layui-inline{
            margin-bottom: 15px;
            margin-right: 10px;
        }
    </style>

    <script>
        $(function () {
            $('#demo-2').fdatepicker({
                format: 'yyyy-mm-dd hh:ii',
                pickTime: true
            });
            $('#demo-3').fdatepicker({
                format: 'yyyy-mm-dd hh:ii',
                pickTime: true
            });
        })
    </script>

</head>

<body>
<c:if test="${requestScope.hotel.inputUser!=null}">
    <div class="cBody">
        <form id="addForm" class="layui-form" action="<%=path%>/logistics/updateList" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">申请人:</label>
                <div class="layui-input-block user">
                        ${requestScope.hotel.supplierTravel.systemUser.name}
                </div>
            </div>
            <input type="hidden" name="supplierTravel.id" value="${param.id}">
            <input type="hidden" name="id" value="${requestScope.hotel.id}">

            <div class="layui-inline">
                <label class="layui-form-label">入住日期:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="stayTime" value="<fmt:formatDate value="${requestScope.hotel.stayTime}" pattern="yyyy-MM-dd"/>" name="stayTime" id="date1" autocomplete="off" class="layui-input" lay-key="2">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">离店日期:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="leaveTime" value="<fmt:formatDate value="${requestScope.hotel.leaveTime}" pattern="yyyy-MM-dd"/>" name="leaveTime" id="date2" autocomplete="off" class="layui-input" lay-key="1">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">酒店名称:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="hotelName" name="hotelName" autocomplete="off" value="${requestScope.hotel.hotelName}" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">酒店地址:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="hotelPlace" name="hotelPlace" autocomplete="off" value="${requestScope.hotel.hotelPlace}" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">总费用:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="price" name="price" autocomplete="off" value="${requestScope.hotel.price}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">记录人:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="inputUser" name="inputUser" autocomplete="off" value="${requestScope.hotel.inputUser}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注:</label>
                <div class="layui-input-block">
                    <textarea name="remarks" lay-verify="remarks" class="layui-textarea">${requestScope.hotel.remarks}</textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="submitUpdate">提交修改</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</c:if>

<%--=============================================================================================--%>
<c:if test="${requestScope.hotel.inputUser==null}">
    <div class="cBody">
        <form id="addForm" class="layui-form" action="<%=path%>/logistics/insertStayList" method="post">
            <div class="layui-form-item">
                <label class="layui-form-label">申请人:</label>
                <div class="layui-input-block user">
                        ${requestScope.hotel.supplierTravel.systemUser.name}
                </div>
            </div>
            <input type="hidden" name="supplierTravel.id" value="${param.id}">

            <div class="layui-inline">
                <label class="layui-form-label">入住日期:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="stayTime" value="<fmt:formatDate value="${requestScope.administrationTicket.departDate}" pattern="yyyy-MM-dd"/>" name="stayTime" id="date1" autocomplete="off" class="layui-input" lay-key="2">
                </div>
            </div>

            <div class="layui-inline">
                <label class="layui-form-label">离店日期:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="leaveTime" value="<fmt:formatDate value="${requestScope.administrationTicket.returnTrip}" pattern="yyyy-MM-dd"/>" name="leaveTime" id="date2" autocomplete="off" class="layui-input" lay-key="1">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">酒店名称:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="hotelName" name="hotelName" autocomplete="off" value="${requestScope.administrationTicket.inputUser}" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">酒店地址:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="hotelPlace" name="hotelPlace" autocomplete="off" value="${requestScope.administrationTicket.inputUser}" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">总费用:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="price" name="price" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">记录人:</label>
                <div class="layui-input-block">
                    <input type="text" lay-verify="inputUser" name="inputUser" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注:</label>
                <div class="layui-input-block">
                    <textarea name="remarks" lay-verify="remarks" class="layui-textarea">${requestScope.suppliterTravel.auditOpinion}</textarea>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="submitBut">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
</c:if>

<script>

    var layer = window.top.layer;
    var index = layer.getFrameIndex(window.name);//先得到当前iframe层的索引
    layui.use(['upload','form','laydate'], function() {
        var form = layui.form,
            upload = layui.upload,
            layer = layui.layer,
            $ = layui.$,
            laydate = layui.laydate;
        //日期
        laydate.render({
            elem: '#date1'
        });
        laydate.render({
            elem: '#date2'
        });

        //监听提交
        form.on('submit(submitBut)', function(data) {
            parent.location.reload(); //刷新父页面
            layer.close(index); //执行关闭
            return;
        });
        form.on('submit(submitUpdate)', function(data) {
            parent.location.reload(); //刷新父页面
            layer.close(index); //执行关闭
            return;
        });
        form.verify({
            inputUser:[
                /^[\u4e00-\u9fa5]{2,5}$/, '您的输入有误，请输入2-5位中文'
            ],//数组的两个值分别代表：[正则匹配、匹配不符时的提示文字]
            remarks:function (value) {
                if(value==""){
                    return "请输入备注";
                }
            },
            price:[
                /^[+]{0,1}(\d+)$/,"请输入整数"
            ],
            stayTime:[
                /\d{4}-\d{2}-\d{2}/,"请输入正确的日期格式,yyyy-MM-dd"
            ],
            leaveTime:[
                /\d{4}-\d{2}-\d{2}/,"请输入正确的日期格式,yyyy-MM-dd"
            ],
            hotelName:function (value) {
                if(value==""){
                    return "请输入酒店名称";
                }
            },
            hotelPlace:function (value) {
                if(value==""){
                    return "请输入酒店名称";
                }
            }
        });
        form.on('select(departProvince)', function(data) {
                var provinceId = $("#departProvince").val();
                $.get(
                    "<%=path%>/logistics/province",
                    {provinceId:provinceId},
                    function (res) {
                        $("#departCity").empty();
                        $.each(res, function (index, item) {
                            $('#departCity').append(new Option(item.name, item.id));// 下拉菜单里添加元素
                        });
                        form.render("select");
                    })
            }
        )
        return false;
    });

</script>

</div>
</body>

</html>
